<template>
	<body>
		<div class="loan_nav col_nav">
			<ul>
				<li><a href="javascript:history.go(-1)"><i class="iconfont">&#xe61e;</i></a></li>
				<li><p>账单</p></li>
				<li></li>
			</ul>
		</div>
		<div class="interval_T">
			
		</div>
		<!-- <div class="record_time"><p>本月</p></div> -->
		<div class="New_record" v-for="b in list">
			<ul>
				<li>
					<i class="iconfont col_dr">&#xe700;</i>
				</li>
				<li>
					<ul>
						<li><p>{{b.memo}}&nbsp;</p></li>
						<li><p>{{billTypeStr(b.billType)}}|【{{billStatusStr(b.status)}}】</p></li>
						<li><p class="col-gray">{{b.billDate}}</p></li>
					</ul>
				</li>
				<li><p class="record_nub">{{b.billMoney}}</p></li>
			</ul>
		</div>
		<div class="btn">
			<input @click="query" type="button" :value="loadText" class="col_more" />
		</div>
		<div style="height:1rem;">

		</div>
	</body>
</template>

<script>
export default {
	data() {
		return {
			params: {
				page: 1,
				limit: 10,
				sidx: 'bill_date',
				order: 'desc'
			},
			list: [],
			loading: false,
			more: true,
			list: []
		}
	},
	computed: {
		loadText() {
			if (this.more) {
				if (this.loading)
					return '正在加载...'
				else
					return '点击加载更多'
			} else {
				return '没有更多数据'
			}
		}
	},
	created() {
		this.query()
	},
	methods: {
		query() {
			if (!this.more || this.loading) return
			this.loading = true
			this.$http.get('/app/bill/list', {
				params: this.params
			}).then(json => {
				const { code, page } = json
				if (code === 0) {
					const { list } = page
					if (list && list.length > 0) {
						this.list = this.list.concat(list)
					} else {
						this.more = false
					}
					this.params.page++
				}
				this.loading = false
			})
		},
		billTypeStr(type) {
			switch(Number(type)) {
				case 1:
					return '充值'
				case 2:
					return '交易'
				case 3:
					return '抽佣'
				case 4:
					return '支付（手续费）'
				case 5:
					return '提现'
				case 0:
					return '退款'
			}
		},
		billStatusStr(status) {
			switch(Number(status)) {
				case 0:
					return '已完成'
				case 1:
					return '审批中'
				case 2:
					return '处理中'
				case -1:
					return '处理失败'
			}
		}
	}
}
</script>

<style>
</style>